﻿//===============================================================================
// Microsoft patterns & practices
// Windows Phone 7 Developer Guide
//===============================================================================
// Copyright © Microsoft Corporation.  All rights reserved.
// This code released under the terms of the 
// Microsoft patterns & practices license (http://wp7guide.codeplex.com/license)
//===============================================================================


namespace AzureToolkit
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Linq.Expressions;

    public interface IAzureTable<T> : IInitializer
    {
        /// <summary>
        /// Gets the query.
        /// </summary>
        /// <value>The query.</value>
        IQueryable<T> Query { get; }

        /// <summary>
        /// Gets the specified predicate.
        /// </summary>
        /// <param name="predicate">The predicate.</param>
        /// <returns></returns>
        T Get(Expression<Func<T, bool>> predicate);

        /// <summary>
        /// Gets all the rows in the table.
        /// </summary>
        /// <returns></returns>
        ICollection<T> GetAll();

        /// <summary>
        /// Gets all the rows in the table filtered by the query expression.
        /// </summary>
        /// <param name="predicate">The predicate.</param>
        /// <returns></returns>
        ICollection<T> GetAll(Expression<Func<T, bool>> predicate);
        /// <summary>
        /// Adds the specified object to the table.
        /// </summary>
        /// <param name="obj">The object.</param>
        void Add(T obj);
        /// <summary>
        /// Adds the specified objects to the table.
        /// </summary>
        /// <param name="objs">The objects.</param>
        void Add(IEnumerable<T> objs);
        /// <summary>
        /// Adds or updates the object.
        /// </summary>
        /// <param name="obj">The object.</param>
        void AddOrUpdate(T obj);
        /// <summary>
        /// Adds or updates the object.
        /// </summary>
        /// <param name="objs">The objects.</param>
        void AddOrUpdate(IEnumerable<T> objs);
        /// <summary>
        /// Deletes the specified object.
        /// </summary>
        /// <param name="obj">The object.</param>
        void Delete(T obj);
        /// <summary>
        /// Deletes the specified objects.
        /// </summary>
        /// <param name="objs">The objects.</param>
        void Delete(IEnumerable<T> objs);
    }
}